package com.flyway.execise.flyway_db.recompile;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static com.flyway.execise.flyway_db.cart.CommonConstants.PREFIX_EXACUTIO_NAME;

/**
 * @date 19-8-4
 * @auther jackliang
 * @description TODO
 */

@Configuration
@ConditionalOnProperty(matchIfMissing = true,
        prefix = PREFIX_EXACUTIO_NAME,
        name = "deploy",
        havingValue = "true")
public class AutoNotifyWatcherConfiguration {

    private static final Logger LOGGER = LoggerFactory.getLogger(AutoNotifyWatcherConfiguration.class);

    @Bean(initMethod = "init")
    @ConditionalOnMissingBean
    public RecompileNotifyWatcher Watcher() {
        LOGGER.info("Init RecompileNotifyWatcher of event notify based on unix poll ");
        return new RecompileNotifyWatcher();
    }

}
